package 非public类;

import java.util.Scanner;

/**
 * @Author: WangYongGan
 * @Date: 2021/11/28 12:25
 * @Description:
 */
public class 继承 {
    public static int getN() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入 N 的值");
        int n = 0;
        try {
            n = scanner.nextInt();
            if (n < 0) {
                throw new Exception();
            } else {
                return n;
            }
        } catch (Exception e) {
            System.out.println("N 必须是正数或者 0");
            return getN();
        }
    }

    public static void main(String[] args) {
      getN();
    }
}

class Rectangle {
    double chang;
    double kuan;

    Rectangle(double chang, double kuan) {
        this.chang = chang;
        this.kuan = kuan;
    }

    double getArea() {
        return chang * kuan;
    }
}

class Rectangular extends Rectangle {
    double gao;
    double chang;
    double kuan;

    Rectangular(double chang, double kuan) {
        super(chang, kuan);
    }


    double getVolume() {//返回体积
        return getArea() * gao;
    }
}

